package file;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;

import freemarker.template.Configuration;
import freemarker.template.DefaultObjectWrapper;
import freemarker.template.Template;
import freemarker.template.TemplateException;

public class CreateHtml {

public static void main(String []args) throws IOException, TemplateException{
	 //创建一个合适的Configration对象  
    Configuration configuration = new Configuration();  
    configuration.setDirectoryForTemplateLoading(new File("/Users/dongweizhao/Documents/project/前端平台/代码生成器/generator/test"));  
    configuration.setObjectWrapper(new DefaultObjectWrapper());  
    configuration.setDefaultEncoding("UTF-8");   //这个一定要设置，不然在生成的页面中 会乱码  
    //获取或创建一个模版。  
    Template template = configuration.getTemplate("test.html");  
    Map<String, Object> paramMap = new HashMap<String, Object>();  
    paramMap.put("key", "测试");  
    Writer writer  = new OutputStreamWriter(new FileOutputStream("/Users/dongweizhao/Documents/project/前端平台/代码生成器/generator/test/success.html"),"UTF-8");  
    template.process(paramMap, writer);  
}	

}
